/*
 * MIT License
 *
 * Copyright (c) 2023 北京凯特伟业科技有限公司
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package com.je.common.base.table.service;

import com.je.common.base.DynaBean;
import java.util.Map;

/**
 * @program: jecloud-common
 * @author: LIULJ
 * @create: 2021-03-01 16:36
 * @description:
 */
public interface BuildingSqlService {

    /**
     * 生成数据库的查询操作(全部是通过预处理的)
     *
     * @param dynaBean
     * @return
     */
    String getInsertSql(DynaBean dynaBean);

    /**
     * 得到Bean修改的sql语句 (主要用于表格列表更新)
     *
     * @param tableCode
     * @param pkName
     * @param changes
     * @return
     */
    String getUpdateSql(String tableCode, String pkName, Map changes);

    /**
     * 研发部:云凤程
     * 生成数据库的根据ID删除的SQl
     *
     * @param dynaBean
     * @return
     */
    String getDeleteByIdSql(DynaBean dynaBean);

    /**
     * 生成数据根据where删除的SQL
     *
     * @param ids       用,分开的主键id串
     * @param tableName 表名称
     * @param idName    表主键名字
     * @return
     */
    String getDeleteByIdsSql(String ids, String tableName, String idName);

    /**
     * 研发部:云凤程
     * 生成根据id查询一条数据的SQL
     *
     * @param dynaBean
     * @return
     */
    String getSelecOnetByIdSql(DynaBean dynaBean);

    /**
     * 生成数据根据where删除的SQL
     *
     * @param dynaBean
     * @return
     */
    String getDeleteByWhereSql(DynaBean dynaBean);

    /**
     * 生成根据ID或者where生成更新BEAN的SQL
     *
     * @param useWhere 是否用whereh
     * @param dynaBean
     * @return
     */
    String getUpdateByIdOrWhereSql(DynaBean dynaBean, boolean useWhere);

    /**
     * 生成根据WHERE查询一条数据的SQL
     *
     * @param dynaBean
     * @return
     */
    String getSelectOneByWhereSql(DynaBean dynaBean);

    /**
     * 生成根据WHERE查询数据的记录数
     *
     * @param dynaBean
     * @return
     */
    String getSelectCountByWhereSql(DynaBean dynaBean);


}
